mainWindow.js ➔ ... ➔ ???   A
last analyzed

Complexity

Conditions 1
Paths 1

Size

Total Lines 4

Duplication

Lines 0
Ratio 0 %

Code Coverage

Tests 0
CRAP Score 2

Importance

Changes 2
Bugs 0 Features 0
Metric Value
cc 1
c 2
b 0
f 0
nc 1
dl 0
loc 4
ccs 0
cts 3
cp 0
crap 2
rs 10
nop 2
1
"use strict";
2
3
const {
4
    BrowserWindow
5
} = require('electron');
6
7
8
const path = require('path');
9
const url = require('url');
10
11
const touchbar = require('./touchbar');
12
13
const open = require("open");
14
15
let createWindow = () => {
16
    let mainWindow;
17
18
    mainWindow = new BrowserWindow({
19
        width: 800,
20
        height: 600
21
    });
22
23
    mainWindow.maximize();
24
25
    mainWindow.loadURL(url.format({
26
        pathname: path.join(__dirname, '../views/index.html'),
27
        protocol: 'file:',
28
        slashes: true
29
    }));
30
31
    mainWindow.webContents.on('new-window', (event, url) => {
32
        event.preventDefault();
33
        open(url);
34
    });
35
36
    // Open the DevTools.
37
    mainWindow.webContents.openDevTools();
38
39
    touchbar.setMainWindow(mainWindow);
40
    mainWindow.setTouchBar(touchbar.touchBar);
41
42
    mainWindow.on('closed', () => {
43
        mainWindow = null;
44
    });
45
};
46
47
module.exports = {
48
    createWindow: createWindow
49
};
50